package com.example.baseweather.utils;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.widget.Toast;

import com.example.baseweather.MyApplication;

public class CommonUtils {


    public static void showToastShort(String message) {
        MyApplication.postMessage(() -> {
            Toast.makeText(MyApplication.getInstance(), message, Toast.LENGTH_SHORT).show();
        });
    }

    public static void showToastLong(String message) {
        MyApplication.postMessage(() -> {
            Toast.makeText(MyApplication.getInstance(), message, Toast.LENGTH_LONG).show();
        });
    }


    public static <T extends Activity> void startAc(Context context, Class<T> clazz) {
        Intent intent = new Intent(context, clazz);
        context.startActivity(intent);
    }

    public static float dp2Px(float dp) {
        return dp * MyApplication.getInstance().getResources().getDisplayMetrics().density;
    }


    public static float px2Dp(float px) {
        return px / MyApplication.getInstance().getResources().getDisplayMetrics().density;
    }


}
